﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace ImageRecognition2.Action
{
    /// <summary>
    /// Use this delegate if no filter is needed, just to execute an action
    /// </summary>
    public class ActionExecuteNonFilterDelegate : AbstractCommand
    {
        protected Delegate m_Delegate = null;

        /// <summary>
        /// Default constructor for common delegates...
        /// </summary>
        /// <param name="_delegate"></param>
        public ActionExecuteNonFilterDelegate(Delegate _delegate)
        {
            m_Delegate = _delegate;
        }

        /// <summary>
        /// Concrete delegate which is not used for a filter
        /// </summary>
        /// <param name="_executeAction"></param>
        public ActionExecuteNonFilterDelegate(ExecuteAction _executeAction)
        {
            m_Delegate = _executeAction;
        }

        /// <summary>
        /// Gets or sets delegate
        /// </summary>
        public Delegate Delegate
        {
            get { return m_Delegate; }
            set { m_Delegate = value; }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public override void Run(object sender, EventArgs e)
        {
            m_Delegate.DynamicInvoke(new object[] { sender, e});
            //Debug.WriteLine("UnsafeBitmap as return type expected, but was NULL");
        }
    }
}
